﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Test;

namespace ORMAC.Test
{
    class Program
    {
        const string TestDataCnn = @"Server=.\SQLExpress;Database=Northwind; Trusted_Connection=Yes";
        static void Main(string[] args)
        {
            IReader orm = new OReader();
            orm.SetConnectionString(TestDataCnn);
            //var res = orm.LoadFromDatabase<OOrders>(o=>o.OrderID==10248,TestDataCnn);
            var res = orm.LoadFromDatabase<OOrders>(o=>o.Customers.ContactName=="Paul Henriot",TestDataCnn);
            if (res != null)
            {
                Console.WriteLine("Number of Orders:"+ res.Count.ToString());
                foreach (OOrders order in res)
                {
                    Console.WriteLine("Order ID:"+ order.OrderID.ToString());
                    if (order.Customers != null)
                    {
                        Console.WriteLine("\tCustomer ID:" + order.Customers.CustomerID.ToString());
                        Console.WriteLine("\tCustomer Name:" + order.Customers.ContactName);
                    }
                }
            }
            Console.ReadKey();
        }
    }
}
